package com.example.hasee.zhcd.Activities.ShangWu;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import com.example.hasee.zhcd.Activities.QianDao.TagActivity;
import com.example.hasee.zhcd.Base.BaseActivity;
import com.example.hasee.zhcd.Bean.EventMsg;
import com.example.hasee.zhcd.R;
import com.example.hasee.zhcd.Util.GlobalParameter;
import com.example.hasee.zhcd.Util.ProgressDialogUtils;

import org.json.JSONArray;
import org.json.JSONObject;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;

import static android.R.attr.key;
import static com.example.hasee.zhcd.Application.App.map;

public class FMInputActivity extends BaseActivity implements TextWatcher {
    private TextView title;
    private ImageView back;
    private ImageView home;
    private Button btn_save;
    /*
    * 收件人
    * */
    private AutoCompleteTextView sirs;
    private EditText fax;
    /*
    * 船代费部分
    */
    private CheckBox CDFBox;
    private CheckBox baoganBox;
    private EditText cdf_1;
    private EditText cdf_2;
    private EditText cdf_result;
    /*
    * 引航费部分
    */
    private CheckBox YHFBox;
    private EditText yhf_1;
    private EditText yhf_2;
    private EditText yhf_3;
    private EditText yhf_result;
    /*
    * 拖轮费部分
    */
    private CheckBox TLFBox;
    private EditText tlf_1;
    private EditText tlf_2;
    private EditText tlf_3;
    private EditText tlf_4;
    private EditText tlf_result;
    /*
    * 系解缆费部分
    */
    private CheckBox XJLFBox;
    private EditText xjlf_1;
    private EditText xjlf_2;
    private EditText xjlf_result;
    /*
    * 停泊费部分
    */
    private CheckBox TBFBox;
    private EditText tbf_1;
    private EditText tbf_2;
    private EditText tbf_3;
    private EditText tbf_result;

    /*
     * 公估费部分
     */
    private CheckBox GGFBox;
    private EditText ggf_1;
    private EditText ggf_2;
    private EditText ggf_result;
    /**
     * 其他
     */
    private CheckBox QTBox;
    private EditText fymc;
    private EditText fyje;
    private HashMap<String, String> loginmap = (HashMap<String, String>) GlobalParameter.get("loginmap");
    private ArrayList<String> sir_list = new ArrayList<String>();
    private HashMap<String, String> codeMap = new HashMap<String, String>();
    private HashMap<String, String> faxMap = new HashMap<String, String>();
    private ArrayAdapter<String> adapter;
    private String strSYN;
    private String strSJR;
    private String strSJRID;
    private String strTel;
    private String strAccount;
    private String strCDF;
    private String strYBSL;
    private String strCDFL;
    private String strCDJE;
    private String strBG;
    private String strYHF;
    private String strYHJD;
    private String strYHCS;
    private String strYHFL;
    private String strYHJE;
    //tuolunfei
    private String strTLF;
    private String strJGTL;
    private String strJGJE;
    private String strLGTL;
    private String strLGJE;
    private String strTLJE;
    //jijielan
    private String strXJL;
    private String strXJLFL;
    private String strXJLCS;
    private String strXJLJE;
    //tingbo
    private String strTBF;
    private String strTBJD;
    private String strTBFL;
    private String strTBTS;
    private String strTBJE;
    //qita
    private String strQT;
    private String strQTFM;
    private String strQTJE;
    //gg
    private String strGGF;
    private String strGGCS;
    private String strGGJE;

    @Override
    public int contentViewId() {
        return R.layout.activity_feimu;
    }

    @Override
    public void set() {
        title.setText("费目录入");
        back.setOnClickListener(this);
        home.setVisibility(View.INVISIBLE);
        btn_save.setOnClickListener(this);
        CDFBox.setChecked(false);
        YHFBox.setChecked(false);
        TLFBox.setChecked(false);
        XJLFBox.setChecked(false);
        TBFBox.setChecked(false);
        GGFBox.setChecked(false);
        baoganBox.setChecked(false);
        if (!baoganBox.isChecked()) {
            cdf_result.setEnabled(false);
        }
        baoganBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                if (b) {
                    cdf_result.setEnabled(true);
                } else {
                    cdf_result.setEnabled(false);
                }
            }
        });
        cdf_1.addTextChangedListener(new CDFWatcher());
        cdf_2.addTextChangedListener(new CDFWatcher());
        yhf_1.addTextChangedListener(new YHFWatcher());
        yhf_2.addTextChangedListener(new YHFWatcher());
        yhf_3.addTextChangedListener(new YHFWatcher());
        tlf_1.addTextChangedListener(new TLFWatcher());
        tlf_2.addTextChangedListener(new TLFWatcher());
        tlf_3.addTextChangedListener(new TLFWatcher());
        tlf_4.addTextChangedListener(new TLFWatcher());
        xjlf_1.addTextChangedListener(new XJLFWatcher());
        xjlf_2.addTextChangedListener(new XJLFWatcher());
        tbf_1.addTextChangedListener(new TBFWatcher());
        tbf_2.addTextChangedListener(new TBFWatcher());
        tbf_3.addTextChangedListener(new TBFWatcher());
        getSir();
    }

    @Override
    public void init() {
//        strSYN = "QHD201802373";
        //{"data": {"user":"陈义军", "role":"wq", "account":"796", "user":"5636"},"rspcode": 2,"rspmessage":""}
        strSYN = getIntent().getExtras().getString("strSYN");
        Log.e("strSYN", strSYN);
        strAccount = loginmap.get("account");
        //ZHSW_zgcb_saveSFYG: {"data":"","rspcode": 1,"rspmessage":"保存成功！"}
//        strAccount = "796";
        back = (ImageView) findViewById(R.id.back);
        home = (ImageView) findViewById(R.id.home);
        title = (TextView) findViewById(R.id.centertitle);
        //联系人
        sirs = (AutoCompleteTextView) findViewById(R.id.sirs);
        fax = (EditText) findViewById(R.id.fax);
        //船代费
        CDFBox = (CheckBox) findViewById(R.id.CDFBox);
        baoganBox = (CheckBox) findViewById(R.id.baoganBox);
        cdf_1 = (EditText) findViewById(R.id.cdf_1);
        cdf_2 = (EditText) findViewById(R.id.cdf_2);
        cdf_result = (EditText) findViewById(R.id.cdf_result);
        //引航费
        YHFBox = (CheckBox) findViewById(R.id.YHFBox);
        yhf_1 = (EditText) findViewById(R.id.yhf_1);
        yhf_2 = (EditText) findViewById(R.id.yhf_2);
        yhf_3 = (EditText) findViewById(R.id.yhf_3);
        yhf_result = (EditText) findViewById(R.id.yhf_result);
        //拖轮费
        TLFBox = (CheckBox) findViewById(R.id.TLFBox);
        tlf_1 = (EditText) findViewById(R.id.tlf_1);
        tlf_2 = (EditText) findViewById(R.id.tlf_2);
        tlf_3 = (EditText) findViewById(R.id.tlf_3);
        tlf_4 = (EditText) findViewById(R.id.tlf_4);
        tlf_result = (EditText) findViewById(R.id.tlf_result);
        //系解缆费
        XJLFBox = (CheckBox) findViewById(R.id.XJLFBox);
        xjlf_1 = (EditText) findViewById(R.id.xjlf_1);
        xjlf_2 = (EditText) findViewById(R.id.xjlf_2);
        xjlf_result = (EditText) findViewById(R.id.xjlf_result);
        //停泊费
        TBFBox = (CheckBox) findViewById(R.id.TBFBox);
        tbf_1 = (EditText) findViewById(R.id.tbf_1);
        tbf_2 = (EditText) findViewById(R.id.tbf_2);
        tbf_3 = (EditText) findViewById(R.id.tbf_3);
        tbf_result = (EditText) findViewById(R.id.tbf_result);
        //公估费
        GGFBox = (CheckBox) findViewById(R.id.GGFBox);
        ggf_1 = (EditText) findViewById(R.id.ggf_1);
        ggf_2 = (EditText) findViewById(R.id.ggf_2);
        ggf_result = (EditText) findViewById(R.id.ggf_result);
        //其他
        QTBox = (CheckBox) findViewById(R.id.QTBox);
        fymc = (EditText) findViewById(R.id.fmmc);
        fyje = (EditText) findViewById(R.id.fmje);
        btn_save = (Button) findViewById(R.id.btn_save);
    }

    @Override
    public void getEventData(EventMsg msg) {
        switch (msg.getAction()) {
            case "ZHSW_zgcb_sjr":
                Log.e("ZHSW_zgcb_sjr", msg.getMsg());
                //{"fcode":"1510", "fsjr":"平潭盛帆", "ffax":"0591-23138835"}
                try {
                    JSONObject json = new JSONObject(msg.getMsg());
                    String rspcode = json.getString("rspcode");
                    String rspmessage = json.getString("rspmessage");
                    if ("0".equals(rspcode)) {
                        JSONArray data = json.getJSONArray("data");
                        for (int i = 0; i < data.length(); i++) {
                            sir_list.add(data.getJSONObject(i).getString("fsjr"));
                            codeMap.put(data.getJSONObject(i).getString("fsjr"), data.getJSONObject(i).getString("fcode"));
                            faxMap.put(data.getJSONObject(i).getString("fsjr"), data.getJSONObject(i).getString("ffax"));
                        }
                        adapter = new ArrayAdapter<String>(FMInputActivity.this,
                                android.R.layout.simple_spinner_dropdown_item, sir_list);
                        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                        sirs.setAdapter(adapter);
                        sirs.setThreshold(1);
                        sirs.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                            @Override
                            public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {

                                fax.setText("");
                            }

                            @Override
                            public void onNothingSelected(AdapterView<?> adapterView) {

                            }
                        });
                        sirs.addTextChangedListener(this);
//                        strSJR = codeMap.get(sir_list.get(i));
//                        fax.setText(faxMap.get(i));
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                getDetail();
                break;
            case "ZHSW_zgcb_SFYGXX":
                ProgressDialogUtils.closeProgressDialog();
                Log.e("ZHSW_zgcb_SFYGXX", msg.getMsg());
                try {
                    JSONObject json = new JSONObject(msg.getMsg());
                    String rspcode = json.getString("rspcode");
                    String rspmessage = json.getString("rspmessage");
                    if ("0".equals(rspcode)) {
                        JSONObject data = json.getJSONArray("data").getJSONObject(0);
                        //净吨
                        yhf_1.setText(data.getString("fcbjd"));
                        tbf_1.setText(data.getString("fcbjd"));
                        //引航费率
                        yhf_2.setText(data.getString("fyhfl"));
                        //银行次数
                        yhf_3.setText(data.getString("fyhcs"));
                        //系解缆费率cishu
                        xjlf_1.setText(data.getString("fxjlfl"));
                        xjlf_2.setText(data.getString("fxjlcs"));
                        //预报数量 船代费费率
                        cdf_1.setText(data.getString("fybsl"));
                        cdf_2.setText(data.getString("fcdfl"));
                        //拖轮数和拖轮金额
                        tlf_1.setText(data.getString("fjgtl"));
                        tlf_3.setText(data.getString("flgtl"));
                        tlf_2.setText(data.getString("ftlje"));
                        tlf_4.setText(data.getString("ftlje"));
                        //停泊费率
//                        tbf_2.setText(data.getString("ftlxs"));

                        tbf_2.setText(data.getString("ftbfl"));
                        //公估
                        ggf_1.setText(data.getString("fggcs"));
                        ggf_2.setText(data.getString("fggje"));
                        BigDecimal ggf1 = new BigDecimal(data.getString("fggcs"));
                        BigDecimal ggf2 = new BigDecimal(data.getString("fggje"));
                        ggf_result.setText(ggf1.multiply(ggf2).doubleValue() + "");
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                break;
            case "ZHSW_zgcb_saveSFYG":
                ProgressDialogUtils.closeProgressDialog();
//                Log.e("ZHSW_zgcb_saveSFYG", msg.getMsg());
                //ZHSW_zgcb_saveSFYG: {"data":"","rspcode": 1,"rspmessage":"保存成功！"}
                try {
                    JSONObject json = new JSONObject(msg.getMsg());
                    String rspcode = json.getString("rspcode");
                    String rspmessage = json.getString("rspmessage");
                    if ("1".equals(rspcode)) {
                        FinishDialog(rspmessage);
                    } else {
                        Toast.makeText(FMInputActivity.this, rspmessage, Toast.LENGTH_LONG).show();
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
                break;
        }
    }

    private void getSir() {
        HashMap<String, String> map = new HashMap<String, String>();
        httpUtils.get("ZHSW_zgcb_sjr", map, "ZHSW_zgcb_sjr");
    }

    private void getDetail() {
        ProgressDialogUtils.createProgressDialog(FMInputActivity.this, "正在获取数据...");
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("strSYN", strSYN);
        httpUtils.get("ZHSW_zgcb_SFYGXX", map, "ZHSW_zgcb_SFYGXX");
    }

    private void save() {
        ProgressDialogUtils.createProgressDialog(FMInputActivity.this, "正在保存数据...");
        //赋值
        strTel = fax.getText().toString().trim();
        if (CDFBox.isChecked()) {
            strCDF = "1";
        } else {
            strCDF = "0";
        }
        strYBSL = cdf_1.getText().toString().trim();
        strCDFL = cdf_2.getText().toString().trim();
        strCDJE = cdf_result.getText().toString().trim();
        if (baoganBox.isChecked()) {
            strBG = "1";
        } else {
            strBG = "0";
        }
        Log.e("canshu", strCDF + "   " +
                strYBSL + "   " +
                strCDFL + "   " +
                strCDJE + "   " + strBG);
        if (YHFBox.isChecked()) {
            strYHF = "1";
        } else {
            strYHF = "0";
        }
        strYHJD = yhf_1.getText().toString().trim();
        strYHCS = yhf_2.getText().toString().trim();
        strYHFL = yhf_3.getText().toString().trim();
        strYHJE = yhf_result.getText().toString().trim();
        if (TLFBox.isChecked()) {
            strTLF = "1";
        } else {
            strTLF = "0";
        }
        strJGTL = tlf_1.getText().toString().trim();
        strJGJE = tlf_2.getText().toString().trim();
        strLGTL = tlf_3.getText().toString().trim();
        strLGJE = tlf_4.getText().toString().trim();
        strTLJE = tlf_result.getText().toString().trim();
        if (XJLFBox.isChecked()) {
            strXJL = "1";
        } else {
            strXJL = "0";
        }
        strXJLFL = xjlf_1.getText().toString().trim();
        strXJLCS = xjlf_2.getText().toString().trim();
        strXJLJE = xjlf_result.getText().toString().trim();
        if (TBFBox.isChecked()) {
            strTBF = "1";
        } else {
            strTBF = "0";
        }
        strTBJD = tbf_1.getText().toString().trim();
        strTBFL = tbf_2.getText().toString().trim();
        strTBTS = tbf_3.getText().toString().trim();
        strTBJE = tbf_result.getText().toString().trim();
        if (GGFBox.isChecked()) {
            strGGF = "1";
        } else {
            strGGF = "0";
        }
        strGGCS = ggf_1.getText().toString().trim();
        strGGJE = ggf_result.getText().toString().trim();
        if (QTBox.isChecked()) {
            strQT = "1";
        } else {
            strQT = "0";
        }
        strQTFM = fymc.getText().toString().trim();
        strQTJE = fyje.getText().toString().trim();
        //放进map
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("strSYN", strSYN);
        map.put("strSJR", strSJR);
        map.put("strSJRID", strSJRID);
        map.put("strTel", strTel);
        map.put("strAccount", strAccount);
        map.put("strCDF", strCDF);
        map.put("strYBSL", strYBSL);
        map.put("strCDFL", strCDFL);
        map.put("strCDJE", strCDJE);
        map.put("strBG", strBG);
        map.put("strYHF", strYHF);
        map.put("strYHJD", strYHJD);
        map.put("strYHCS", strYHCS);
        map.put("strYHFL", strYHFL);
        map.put("strYHJE", strYHJE);
        map.put("strTLF", strTLF);
        map.put("strJGTL", strJGTL);
        map.put("strJGJE", strJGJE);
        map.put("strLGTL", strLGTL);
        map.put("strLGJE", strLGJE);
        map.put("strTLJE", strTLJE);
        map.put("strXJL", "");
        map.put("strXJLFL", "");
        map.put("strXJLCS", "");
        map.put("strXJLJE", "");
        map.put("strTBF", strTBF);
        map.put("strTBJD", strTBJD);
        map.put("strTBFL", strTBFL);
        map.put("strTBTS", strTBTS);
        map.put("strTBJE", strTBJE);
        map.put("strGGF", strGGF);
        map.put("strGGCS", strGGCS);
        map.put("strGGJE", strGGJE);
        map.put("strQT", strQT);
        map.put("strQTFM", strQTFM);
        map.put("strQTJE", strQTJE);
        httpUtils.get("ZHSW_zgcb_saveSFYG", map, "ZHSW_zgcb_saveSFYG");
    }

    private void FinishDialog(String message) {
        AlertDialog.Builder builder = new AlertDialog.Builder(FMInputActivity.this);
        builder.setMessage(message);
        builder.setTitle("提示");
        builder.setNegativeButton("确认", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface arg0, int arg1) {
                // TODO Auto-generated method stub
                arg0.dismiss();
                FMInputActivity.this.finish();
            }
        });
        builder.create().setCanceledOnTouchOutside(false);
        builder.setCancelable(false);
        builder.show();
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
            case R.id.btn_save:
                save();
                break;
        }
    }

    @Override
    public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

    }

    @Override
    public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

    }

    @Override
    public void afterTextChanged(Editable editable) {
        strSJR = sirs.getText().toString();
        strSJRID = codeMap.get(sirs.getText().toString());
        fax.setText(faxMap.get(sirs.getText().toString()));
    }

    class CDFWatcher implements TextWatcher {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
            //限制两位
            String temp = editable.toString();
            int posDot = temp.indexOf(".");
//            if (posDot <= 0) return;
            if (posDot > 0) {
                if (temp.length() - posDot - 1 > 2) {
                    editable.delete(posDot + 3, posDot + 4);
                }
            }
            //算数
            if (cdf_1.getText().toString().length() != 0
                    && cdf_2.getText().toString().length() != 0
                    && !".".equals(cdf_1.getText().toString())
                    && !".".equals(cdf_2.getText().toString())) {
                BigDecimal cdf1 = new BigDecimal(cdf_1.getText().toString());
                BigDecimal cdf2 = new BigDecimal(cdf_2.getText().toString());
                cdf_result.setText(cdf1.multiply(cdf2).doubleValue() + "");
            }
        }
    }

    class YHFWatcher implements TextWatcher {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
            //限制两位
            String temp = editable.toString();
            int posDot = temp.indexOf(".");
//            if (posDot <= 0) return;
            if (posDot > 0) {
                if (temp.length() - posDot - 1 > 2) {
                    editable.delete(posDot + 3, posDot + 4);
                }
            }
            //算数
            if (yhf_1.getText().toString().length() != 0
                    && yhf_2.getText().toString().length() != 0
                    && yhf_3.getText().toString().length() != 0
                    && !".".equals(yhf_1.getText().toString())
                    && !".".equals(yhf_2.getText().toString())
                    && !".".equals(yhf_3.getText().toString())) {
                BigDecimal yhf1 = new BigDecimal(yhf_1.getText().toString());
                BigDecimal yhf2 = new BigDecimal(yhf_2.getText().toString());
                BigDecimal yhf3 = new BigDecimal(yhf_3.getText().toString());
                yhf_result.setText(yhf1.multiply(yhf2).multiply(yhf3).doubleValue() + "");
            }
        }
    }

    class TLFWatcher implements TextWatcher {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
            //限制两位
            String temp = editable.toString();
            int posDot = temp.indexOf(".");
//            if (posDot <= 0) return;
            if (posDot > 0) {
                if (temp.length() - posDot - 1 > 2) {
                    editable.delete(posDot + 3, posDot + 4);
                }
            }
            //算数
            if (tlf_1.getText().toString().length() != 0
                    && tlf_2.getText().toString().length() != 0
                    && tlf_3.getText().toString().length() != 0
                    && tlf_4.getText().toString().length() != 0
                    && !".".equals(tlf_1.getText().toString())
                    && !".".equals(tlf_2.getText().toString())
                    && !".".equals(tlf_3.getText().toString())
                    && !".".equals(tlf_4.getText().toString())) {
                BigDecimal tlf1 = new BigDecimal(tlf_1.getText().toString());
                BigDecimal tlf2 = new BigDecimal(tlf_2.getText().toString());
                BigDecimal result1 = tlf1.multiply(tlf2);
                BigDecimal tlf3 = new BigDecimal(tlf_3.getText().toString());
                BigDecimal tlf4 = new BigDecimal(tlf_4.getText().toString());
                BigDecimal result2 = tlf3.multiply(tlf4);
                tlf_result.setText(result1.add(result2).doubleValue() + "");
            }
        }
    }

    class XJLFWatcher implements TextWatcher {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
            //限制两位
            String temp = editable.toString();
            int posDot = temp.indexOf(".");
//            if (posDot <= 0) return;
            if (posDot > 0) {
                if (temp.length() - posDot - 1 > 2) {
                    editable.delete(posDot + 3, posDot + 4);
                }
            }
            //算数
            if (xjlf_1.getText().toString().length() != 0
                    && xjlf_2.getText().toString().length() != 0
                    && !".".equals(xjlf_1.getText().toString())
                    && !".".equals(xjlf_2.getText().toString())) {
                BigDecimal xjlf1 = new BigDecimal(xjlf_1.getText().toString());
                BigDecimal xjlf2 = new BigDecimal(xjlf_2.getText().toString());
                xjlf_result.setText(xjlf1.multiply(xjlf2).doubleValue() + "");
            }
        }
    }

    class TBFWatcher implements TextWatcher {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
            //限制两位
            String temp = editable.toString();
            int posDot = temp.indexOf(".");
//            if (posDot <= 0) return;
            if (posDot > 0) {
                if (temp.length() - posDot - 1 > 2) {
                    editable.delete(posDot + 3, posDot + 4);
                }
            }
            //算数
            if (tbf_1.getText().toString().length() != 0
                    && tbf_2.getText().toString().length() != 0
                    && tbf_3.getText().toString().length() != 0
                    && !".".equals(tbf_1.getText().toString())
                    && !".".equals(tbf_2.getText().toString())
                    && !".".equals(tbf_3.getText().toString())) {
                BigDecimal tbf1 = new BigDecimal(yhf_1.getText().toString());
                BigDecimal tbf2 = new BigDecimal(yhf_2.getText().toString());
                BigDecimal tbf3 = new BigDecimal(yhf_3.getText().toString());
                tbf_result.setText(tbf1.multiply(tbf2).multiply(tbf3).doubleValue() + "");
            }
        }
    }
}
